package org.lilystudio.veryftp.util;

import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.search.FullTextSession;
/**
 * 创建FullTextSession实例
 * 字段sessionFactory需要spring注入
 * 
 * @author fnight
 *
 */

public class SessionUtil {
	private SessionFactory sessionFactory;		
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public FullTextSession createFullTextSession(){
		Session session =sessionFactory.openSession();
		FullTextSession fullTextSession = org.hibernate.search.Search.createFullTextSession(session);
		
		//设置为手动刷新
		fullTextSession.setFlushMode(FlushMode.MANUAL);
		
		return fullTextSession;
	}
	

}
